// pages/apply/select/item_select.js
Page({
  /**
   * 页面的初始数据
   */
  data: {
    apply_items:[
      { TYPENAME: '工伤评残', TYPECODE: '01A' }, { TYPENAME: '伤残等级鉴定', TYPECODE: '03A' }, 
      { TYPENAME: '停工留薪期确认', TYPECODE: '05A' }, { TYPENAME: '延长停工留薪期确认', TYPECODE: '07A' }, 
      { TYPENAME: '配置辅助器具确认', TYPECODE: '09A' }, { TYPENAME: '腰椎间盘突出与外伤有关联', TYPECODE: '11A' }, 
      { TYPENAME: '工伤直接导致其他疾病确认', TYPECODE: '13A' }, { TYPENAME: '护理依赖等级鉴定', TYPECODE: '15A' }, 
      { TYPENAME: '供养亲属完全丧失劳动能力鉴定', TYPECODE: '17A' }, { TYPENAME: '复查鉴定', TYPECODE: '19A' }, 
      { TYPENAME: '更换辅助器具确认', TYPECODE: '21A' }, { TYPENAME: '工伤康复鉴定确认', TYPECODE: '23A' }, 
      { TYPENAME: '旧伤复发确认', TYPECODE: '25B' }, { TYPENAME: '医疗依赖确认', TYPECODE: '27B' }, 
      { TYPENAME: '因病提前退休鉴定', TYPECODE: '29B' }, { TYPENAME: '其他委托事项', TYPECODE: '31B' }, 
      { TYPENAME: '非因工致残', TYPECODE: '33B' }, { TYPENAME: '伤残等级鉴定', TYPECODE: '35' }, 
      { TYPENAME: '生活自理障碍等级鉴定', TYPECODE: '37' }, { TYPENAME: '因工伤导致死亡的确认', TYPECODE: '39' }, 
      { TYPENAME: '安装配置伤残辅助器具确认', TYPECODE: '41' }, { TYPENAME: '工伤直接导致疾病确认', TYPECODE: '43' }, 
      { TYPENAME: '工伤复发确认', TYPECODE: '45' }, { TYPENAME: '康复可能性确认', TYPECODE: '47' }, 
      { TYPENAME: '供养亲属完全丧失劳动能力鉴定', TYPECODE: '49' }, { TYPENAME: '停工留薪期确认', TYPECODE: '50' }, 
      { TYPENAME: '其他', TYPECODE: '51' }, { TYPENAME: '延长停工留薪期确认', TYPECODE: '52' },
      { TYPENAME: '完全丧失提前退休鉴定', TYPECODE: '65' }, { TYPENAME: '康复延长期确认', TYPECODE: '67' },
      { TYPENAME: '康复再次鉴定确认', TYPECODE: '69' }
    ],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
  
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  formSubmit: function (e) { 
    var self = this;
    var items = e.detail.value.apply_items_selected;
    var itemsvalue = '';
    var itemscode = '';
    for (var i = 0; i <items.length;i++){
      itemscode += self.data.apply_items[items[i]].TYPECODE;
      itemsvalue += self.data.apply_items[items[i]].TYPENAME;
      if (i < items.length-1){
        itemsvalue += ',';
        itemscode += ',';
      }
    }
    wx.setStorage({
      key: "apply_items_selected",
      data: itemsvalue, 
      success: function (res) {
        console.log('Storage发生了set事件，携带数据为：', e.detail.value.apply_items_selected);
      }
    })
    wx.setStorage({
      key: "apply_items_code",
      data: itemsvalue,
      success: function (res) {
        console.log('apply_items_code：', itemsvalue);
      }
    })
    //关闭当前页面
    wx.navigateBack({});
  },
})

function getCodeByName(name){
  if (name == '工伤评残') return '01A';
}